home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 1998 November / IRIX 6.5.2 Base Documentation November 1998.img / usr / share / catman / p_man / cat3 / perl5 / Tie::Hash.z / Tie::Hash
Text File  |  1998-10-30  |  4KB  |  133 lines

  1.  
  2.  
  3.  
  4. TTTTiiiieeee::::::::HHHHaaaasssshhhh((((3333))))                                                      TTTTiiiieeee::::::::HHHHaaaasssshhhh((((3333))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      Tie::Hash, Tie::StdHash - base class definitions for tied hashes
  10.  
  11. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  12.          package NewHash;
  13.          require Tie::Hash;
  14.  
  15.          @ISA = (Tie::Hash);
  16.  
  17.          sub DELETE { ... }          # Provides needed method
  18.          sub CLEAR { ... }           # Overrides inherited method
  19.  
  20.  
  21.          package NewStdHash;
  22.          require Tie::Hash;
  23.  
  24.          @ISA = (Tie::StdHash);
  25.  
  26.          # All methods provided by default, define only those needing overrides
  27.          sub DELETE { ... }
  28.  
  29.  
  30.          package main;
  31.  
  32.          tie %new_hash, 'NewHash';
  33.          tie %new_std_hash, 'NewStdHash';
  34.  
  35.  
  36. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  37.      This module provides some skeletal methods for hash-tying classes. See
  38.      the _p_e_r_l_t_i_e manpage for a list of the functions required in order to tie
  39.      a hash to a package. The basic TTTTiiiieeee::::::::HHHHaaaasssshhhh package provides a new method,
  40.      as well as methods TIEHASH, EXISTS and CLEAR. The TTTTiiiieeee::::::::SSSSttttddddHHHHaaaasssshhhh package
  41.      provides most methods required for hashes in the _p_e_r_l_t_i_e manpage. It
  42.      inherits from TTTTiiiieeee::::::::HHHHaaaasssshhhh, and causes tied hashes to behave exactly like
  43.      standard hashes, allowing for selective overloading of methods. The new
  44.      method is provided as grandfathering in the case a class forgets to
  45.      include a TIEHASH method.
  46.  
  47.      For developers wishing to write their own tied hashes, the required
  48.      methods are briefly defined below. See the the _p_e_r_l_t_i_e manpage section
  49.      for more detailed descriptive, as well as example code:
  50.  
  51.      TIEHASH classname, LIST
  52.           The method invoked by the command tie %hash, classname. Associates a
  53.           new hash instance with the specified class. LIST would represent
  54.           additional arguments (along the lines of the _A_n_y_D_B_M__F_i_l_e manpage and
  55.           compatriots) needed to complete the association.
  56.  
  57.      STORE this, key, value
  58.           Store datum _v_a_l_u_e into _k_e_y for the tied hash _t_h_i_s.
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. TTTTiiiieeee::::::::HHHHaaaasssshhhh((((3333))))                                                      TTTTiiiieeee::::::::HHHHaaaasssshhhh((((3333))))
  71.  
  72.  
  73.  
  74.      FETCH this, key
  75.           Retrieve the datum in _k_e_y for the tied hash _t_h_i_s.
  76.  
  77.      FIRSTKEY this
  78.           Return the (key, value) pair for the first key in the hash.
  79.  
  80.      NEXTKEY this, lastkey
  81.           Return the next (key, value) pair for the hash.
  82.  
  83.      EXISTS this, key
  84.           Verify that _k_e_y exists with the tied hash _t_h_i_s.
  85.  
  86.      DELETE this, key
  87.           Delete the key _k_e_y from the tied hash _t_h_i_s.
  88.  
  89.      CLEAR this
  90.           Clear all values from the tied hash _t_h_i_s.
  91.  
  92. CCCCAAAAVVVVEEEEAAAATTTTSSSS
  93.      The the _p_e_r_l_t_i_e manpage documentation includes a method called DESTROY as
  94.      a necessary method for tied hashes. Neither TTTTiiiieeee::::::::HHHHaaaasssshhhh nor TTTTiiiieeee::::::::SSSSttttddddHHHHaaaasssshhhh
  95.      define a default for this method. This is a standard for class packages,
  96.      but may be omitted in favor of a simple default.
  97.  
  98. MMMMOOOORRRREEEE IIIINNNNFFFFOOOORRRRMMMMAAAATTTTIIIIOOOONNNN
  99.      The packages relating to various DBM-related implemetations (_D_B__F_i_l_e,
  100.      _N_D_B_M__F_i_l_e, etc.) show examples of general tied hashes, as does the the
  101.      _C_o_n_f_i_g manpage module. While these do not utilize TTTTiiiieeee::::::::HHHHaaaasssshhhh, they serve
  102.      as good working examples.
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.